home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- ********************************************************************************
- ********************************************************************************
-
- PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
- THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
-
- P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
-
-
- ********************************************************************************
- ********************************************************************************
- *******************************************************************************/
-
- #include "header.h"
-
- lock_on(cp,chno)
- register struct player *cp;
- int chno;
- {
- register struct player *x;
- int lockok;
-
- lockok=OFF;
- x=startlist;
- while (x!=NULL)
- {
- if (x==cp) {x=x->next; continue;}
- if ((cp->xpos==x->xpos)&&(cp->ypos==x->ypos))
- {
- cp->channel[chno].enemy=x;
- cp->channel[chno].xloc=0;
- cp->channel[chno].yloc=0;
- lockok=ON;
- plot1(cp," Tractor beam locked onto enemy captain! ");
- plot2(cp," ");
- x=NULL;
- } else
- x=x->next;
- }
- if (lockok==OFF)
- {
- cp->channel[chno].enemy=NULL;
- cp->channel[chno].xloc=cp->xpos;
- cp->channel[chno].yloc=cp->ypos;
- if (inuniv(cp->xpos,cp->ypos)=='*')
- {
- plot1(cp," Tractor beam locked onto starbase captain! ");
- plot2(cp," ");
- } else
- {
- plot1(cp," Tractor beam locked onto this quadrant captain! ");
- plot2(cp," ");
- }
- }
-
- }
-
- displaybeams(cp)
- register struct player *cp;
- {
- char str[7];
- int i;
- poscurs(cp,23,22);
- for (i=0; i<4; i++)
- {
- sprintf(str,"%1d)",(i+1));
- write(cp->fd,str,2);
- if (cp->channel[i].enemy==NULL)
- {
- if (inuniv(cp->channel[i].xloc,cp->channel[i].yloc)=='*')
- write(cp->fd,"*:",2);
- sprintf(str,"%3d,",cp->channel[i].xloc);
- write(cp->fd,str,4);
- sprintf(str,"%3d ",cp->channel[i].yloc);
- write(cp->fd,str,4);
- } else
- {
- sprintf(str,"%1c:",cp->channel[i].enemy->id);
- write(cp->fd,str,2);
- sprintf(str,"%3d,",cp->channel[i].enemy->xpos);
- write(cp->fd,str,4);
- sprintf(str,"%3d ",cp->channel[i].enemy->ypos);
- write(cp->fd,str,4);
- }
- }
- }
-
- auto_pilot(cp)
- register struct player *cp;
- {
- int x;
- x=cp->flyto;
- if (cp->channel[x].enemy==NULL)
- {
- if (cp->xpos!=cp->channel[x].xloc)
- {
- if (cp->xpos<cp->channel[x].xloc) cp->xvel=1; else cp->xvel= -1; } else cp->xvel=0;
- if (cp->ypos!=cp->channel[x].yloc)
- {
- if (cp->ypos<cp->channel[x].yloc) cp->yvel=1; else cp->yvel= -1;
- } else cp->yvel=0;
- } else
- {
- if (cp->xpos!=cp->channel[x].enemy->xpos)
- {
- if (cp->xpos<cp->channel[x].enemy->xpos) cp->xvel=1; else cp->xvel= -1;
- } else cp->xvel=0;
- if (cp->ypos!=cp->channel[x].enemy->ypos)
- {
- if (cp->ypos<cp->channel[x].enemy->ypos) cp->yvel=1; else cp->yvel= -1;
- } else cp->yvel=0;
- }
-
- /* arrival at location*/
- if ((cp->xvel==0)&&(cp->yvel==0))
- {
- plotstatus(cp,3);
- cp->flyto= -1;
- plot1(cp," Sulu : We have arrived at the programmed location Sir. ");
- plot2(cp," ");
- }
- }
-
-